package com.cloudbroker.bcs.platform.ltb.middle.service.impl;

import com.cloudbroker.bcs.common.dao.base.DAOBase;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.admin.vo.UserQueryForm;
import com.cloudbroker.bcs.platform.ltb.common.config.ConfigValues;
import com.cloudbroker.bcs.platform.ltb.middle.dao.UserDAO;
import com.cloudbroker.bcs.platform.ltb.middle.entity.UserEntity;
import com.cloudbroker.bcs.platform.ltb.middle.service.UserService;
import com.cloudbroker.bcs.platform.ltb.middle.service.base.TenantServiceImplBase;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by tianrui on 2016/7/5.
 */
@Service
public class UserServiceImpl extends TenantServiceImplBase<UserEntity, String>
        implements UserService{

    @Resource
    private UserDAO userDAO;

    @Override
    protected DAOBase<UserEntity, String> getDAO() {
        return userDAO;
    }

    @Override
    public UserEntity userLoginVerify(UserEntity userEntity) {
        return userDAO.userLoginVerify(userEntity);
    }

    @Override
    public long getAccountID(UserEntity userEntity) {
        return userDAO.getAccountID(userEntity);
    }

    @Override
    public int restPassword(UserEntity userEntity) {
        return userDAO.restPassword(userEntity);
    }

    @Override
    public void updatePassword(UserEntity userEntity) {
        userDAO.updatePassword(userEntity);
    }

    @Override
    public UserEntity getUserEntity(UserEntity userEntity) {
        return userDAO.getUserEntity(userEntity);
    }

    @Override
    public void addUser(UserEntity userEntity) {
        super.save(userEntity);
    }

    @Override
    public String getUserStatus(UserEntity userEntity) {
        return null;
    }

    @Override
    public void updateUserAvatar(UserEntity userEntity) {
        userDAO.updateAvatar(userEntity);
    }

    @Override
    public void updateUserAliasName(UserEntity userEntity) {
        userDAO.updateAliasName(userEntity);
    }

    @Override
    public void updateUserStatus(UserEntity userEntity) {
        userDAO.updateUserStatus(userEntity);
    }

    public List<UserEntity> queryByName(UserQueryForm form){
        return userDAO.queryByName(form);
    }

    public void updateUserLoginTime(UserEntity userEntity){
        userDAO.updateUserLoginTime(userEntity);
    }

    @Override
    public List<UserEntity> getUserList(List<Long> idList) {
        return userDAO.getUserAvatar(idList);
    }


    public void updateID(Long new_id, Long user_id){
         userDAO.updateID(new_id,user_id);
    }

    public void updateInviteNum(UserEntity userEntity){
        userDAO.updateInviteNum(userEntity);
    }

    public UserEntity findByInviteCode(UserEntity userEntity){
        return userDAO.findByInviteCode(userEntity);
    }

    public void updateOpenId(UserEntity userEntity){
        userDAO.updateOpenId(userEntity);
    }

    @Override
    public void updateAnswerNum(UserEntity leader) {
        userDAO.updateAnswerNum(leader);
    }
}
